local zheying = fk.CreateSkill {
  name = "th_zheying",
  max_round_use_time = 2,
}

local spec = { ---@type TrigSkelSpec<fun(self: TriggerSkill, event: DamageEvent, target: ServerPlayer, player: ServerPlayer, data: DamageData):any>
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(zheying.name)
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local to = room:askToChoosePlayers(player, {
      targets = room:getOtherPlayers(player, false),
      min_num = 1,
      max_num = 1,
      prompt = "#th_zheying-choose",
      skill_name = zheying.name,
      cancelable = true
    })
    if #to == 1 then
      event:setCostData(self, { tos = to, anim_type = (event == fk.Damage and "offensive" or "defensive") })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local dat = event:getCostData(self)
    local to = dat.tos[1]
    room:loseHp(player, 1, zheying.name)
    local cards = room:askToDiscard(to, {
      min_num = 2,
      max_num = 2,
      include_equip = true,
      skill_name = zheying.name,
      cancelable = true,
      prompt = "#th_zheying-ask"
    })
    if #cards < 2 then
      room:loseHp(to, 1, zheying.name)
    end
  end,
}

zheying:addEffect(fk.Damage, spec, { check_skill_limit = true })
zheying:addEffect(fk.Damaged, spec, { check_skill_limit = true })

Fk:loadTranslationTable{
  ["th_zheying"] = "折樱",
  [":th_zheying"] = "每轮限两次，你造成或受到伤害后，你可以失去1点体力，令一名其他角色选择一项：1.弃置两张牌；2.失去1点体力。",

  ["#th_zheying-choose"] = "折樱：你可以失去1点体力，令一名角色弃置两张牌或失去1点体力",
  ["#th_zheying-ask"] = "折樱：你需弃置两张牌，否则将失去1点体力",
}

return zheying